package model;

import android.util.Log;

import base.BaseModel;
import base.BaseObserver;
import base.ResultCallBack;
import bean.ResultBean;
import bean.VideoDataBean;
import jiyun.com.yiyanmeng.http.HttpManager;
import jiyun.com.yiyanmeng.http.MySerivce;
import presenter.VideoDataPresenter;
import utils.RxUtil;

/**
 * Created by 裘翔 on 2019/11/11.
 */

public class VideoDataModel extends BaseModel{

    public void loadData(final ResultCallBack<VideoDataBean> callBack, int id) {
        MySerivce mySerivce = HttpManager.getInstance().getSerivce();
        mySerivce.getVideoData(id)
                .compose(RxUtil.<ResultBean<VideoDataBean>>changeThread())
                .compose(RxUtil.<VideoDataBean>changeResult())
                .subscribe(new BaseObserver<VideoDataBean>() {
                    @Override
                    public void onSuccess(VideoDataBean dataBean) {
                        Log.i("sssssss",dataBean.toString());
                       callBack.onSuccess(dataBean);
                    }

                    @Override
                    public void onFail(String error) {
                        Log.i("sssssss",error.toString());
                       callBack.onFail(error);
                    }
                });
    }
}
